#/bin/bash
export DATE=`date +"%Y%m%d"`  
BASEDIR="/Users/hbu/pgdata/archivedir"  

if [ ! -d $BASEDIR/$DATE ]; then  
  mkdir -p $BASEDIR/$DATE  
  if [ ! -d $BASEDIR/$DATE ]; then  
    echo "error mkdir -p $BASEDIR/$DATE"  
    exit 1  
  fi  
fi  

cp $1 $BASEDIR/$DATE/$2  
if [ $? -eq 0 ]; then  
  exit 0  
else  
  echo -e "cp $1 $BASEDIR/$DATE/$2 error"  
  exit 1  
fi  

echo -e "backup failed"  
exit 1

